<?php
session_start();
if(!isset($_SESSION['username'])){
	if(isset($_POST['username']) && isset($_POST['password'])){
		if (file_exists('config.inc.php')) {
			require('config.inc.php');
		  }else{
			$username = 'admin';
			$hash_password = 'e10adc3949ba59abbe56e057f20f883e';
		  }
		$user = $_POST['username'];
		$pass = MD5($_POST['password']);

		if($username == $user && $hash_password == $pass){
			//登录成功
			$_SESSION['username'] = $username;
			require('main.php');
			exit();
		}		
	}
} else{
	require('main.php');
	exit();
}
header('location:login.html');
?>